/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ihmprojet.core.model;

import ihmprojet.core.OperateurComparator;
import ihmprojet.core.model.operateur.OperateurUnaire;
import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Rémi PIOTAIX <remi.piotaix@gmail.com>
 */
public class Sommet implements Serializable {

    public void sort() {
        Collections.sort(opUnaires, opC);
    }

    public enum Type {

        ABSTRACTION, UTILISATEUR, APPLICATION, INTERACTION
    }
    private List<OperateurUnaire> opUnaires = new LinkedList<>();
    private Type type = Type.ABSTRACTION;
    private String nom;
    private OperateurComparator opC = new OperateurComparator();

    public Sommet(String nom) {
        this(nom, Type.ABSTRACTION);

        Collections.sort(opUnaires, opC);
    }

    public Sommet(String nom, Type type) {
        this.nom = nom;
        this.type = type;
    }

    public Sommet(String nom, Type type, String desc) {
        this.nom = nom;
        this.type = type;
        this.description = desc;
    }

    public Sommet(Sommet sommet) {
        this(sommet.getNom(), sommet.getType());
        for (OperateurUnaire ou : sommet.getOpUnaires()) {
            this.opUnaires.add(new OperateurUnaire(ou));
        }
    }

    public void setNom(String nom) {
        this.nom = nom;
    }
    private String description = "";

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Type getType() {
        Collections.sort(opUnaires, opC);
        return type;

    }

    public void setType(Type type) {
        this.type = type;
    }

    public String getNom() {
        return nom;
    }

    @Override
    public String toString() {
        String s = getNom();
        for (OperateurUnaire u : opUnaires) {
            s = u.decorate(s);
        }

        return s;
    }

    public java.util.List<OperateurUnaire> getOpUnaires() {
        return opUnaires;
    }
}
